/**
 * 
 */
package es.ibm.santillana.mdm.integration;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.ibm.pim.attribute.AttributeInstance;
import com.ibm.pim.catalog.item.BaseItem;
import com.ibm.pim.catalog.item.Item;
import com.ibm.pim.context.Context;

import es.ibm.santillana.mdm.common.util.ConstSantillana;

/**
 * @author Benito
 *
 */
public class IntegrationChanges {
	
	private HashMap<String, ArrayList <Modification>>  insert;
	private HashMap<String, ArrayList <Modification>>  update;
	private HashMap<String, ArrayList <Modification>>  delete;
	private String sCtgName;
	private String sPkItem;
	private Context context;
	public BaseItem item;
	
	public String getsCtgName() {
		return sCtgName;
	}



	public void setsCtgName(String sCtgName) {
		this.sCtgName = sCtgName;
	}



	public String getsPkItem() {
		return sPkItem;
	}



	public void setsPkItem(String sPkItem) {
		this.sPkItem = sPkItem;
	}




	
	public HashMap<String, ArrayList<Modification>> getInsert() {
		return insert;
	}



	public void setInsert(HashMap<String, ArrayList<Modification>> insert) {
		this.insert = insert;
	}



	public HashMap<String, ArrayList<Modification>> getUpdate() {
		return update;
	}



	public void setUpdate(HashMap<String, ArrayList<Modification>> update) {
		this.update = update;
	}



	public HashMap<String, ArrayList<Modification>> getDelete() {
		return delete;
	}



	public void setDelete(HashMap<String, ArrayList<Modification>> delete) {
		this.delete = delete;
	}



	
	
	
	public IntegrationChanges (String catalogName,String sPk, Context ctx) {
		this.insert = new HashMap<String, ArrayList <Modification>> ();
		this.update = new HashMap<String, ArrayList <Modification>> ();
		this.delete = new HashMap<String, ArrayList <Modification>> ();
		this.sCtgName = catalogName;
		this.sPkItem = sPk;
		this.context = ctx;
	
		
	}



	public Context getContext() {
		return context;
	}



	public void setContext(Context context) {
		this.context = context;
	}






	public void writeAdds() {
		System.out.println("Integration changessss add");
		Collection<String> collTag = this.insert.keySet();
		Iterator <String> it = collTag.iterator();
		while (it.hasNext()) {
			String sTag = it.next();
			ArrayList <Modification> listmod = this.insert.get(sTag);
			Iterator <Modification> iterator = listmod.iterator();
			System.out.println(sTag);
			while (iterator.hasNext()) {
				List <AttributeInstance> list = iterator.next().getChanges();
				Iterator <AttributeInstance> iterinst = list.iterator();
				while (iterinst.hasNext()) {
					System.out.println(iterinst.next().getPath());
				}
			}
		}
		System.out.println("Salgo de integration chages add y el que sale descansa");
	}
	
	public void writeMods() {
		System.out.println("Integration changessss modsssss");
		Collection<String> collTag = this.update.keySet();
		Iterator <String> it = collTag.iterator();
		while (it.hasNext()) {
			String sTag = it.next();
			ArrayList <Modification> listmod = this.update.get(sTag);
			Iterator <Modification> iterator = listmod.iterator();
			System.out.println(sTag);
			while (iterator.hasNext()) {
				List <AttributeInstance> list = iterator.next().getChanges();
				Iterator <AttributeInstance> iterinst = list.iterator();
				while (iterinst.hasNext()) {
					System.out.println(iterinst.next().getPath());
				}
			}
		}
		System.out.println("Salgo de integration chages mod y el que sale descansa");
	}
}










